<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>24.改变构造函数原型并不是继承</title>
</head>

<body>
</body>
<script>
  // js原型的继承不是改变构造函数的原型，下面两个构造函数的原型同时指向 User.prototype 会导致互相覆盖的问题
  function User () { }
  User.prototype.getUserName = function () { };

  function Admin () { }
  Admin.prototype = User.prototype;;
  Admin.prototype.role = function () {
    console.log('admin role');
  };

  function Member () { }
  Member.prototype = User.prototype;;
  Member.prototype.role = function () {
    console.log('member role');
  };
  let a = new Admin(); //member role
  let m = new Member();//member role

  a.role();
  m.role();
</script>

</html>